﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Model;
using BLL;
using Ysb.Components;

public partial class Admin_log : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (AdminCheck.Check(this, 27))
        {

            if (!Page.IsPostBack)
            {
                select.DataSource = new PublicSqlService().GetData("*", "logtype", "");
                select.DataTextField = "name";
                select.DataValueField = "name";
                select.DataBind();
                select.Items.Insert(0, new ListItem("类别", "0"));
                DataLoad("");
            }
        }
        else
        {
            Response.Redirect(AdminCheck.RedirectPage);
        }


    }
    private void DataLoad(string sql)
    {
        ViewState["Sql"] = sql;
        int count = new PublicSqlService().GetCoun("id", "log", sql);
        NewsPage.RecordCount = count;

        BindData(sql);


    }
    private void BindData(string sql)
    {
        spbill.DataSource = new PublicSqlService().GetDataPage("log", NewsPage.PageCount, NewsPage.PageSize, NewsPage.CurrentPageIndex, "id", 1, true, "*", sql);
        spbill.DataBind();

    }
    protected void NewsPage_PageChanged(object sender, EventArgs e)
    {
        BindData((string)ViewState["Sql"]);
    }



    protected void okntn_Click(object sender, ImageClickEventArgs e)
    {
        string sql = "1=1";
        if (keytxt.Value.Trim() != "")
        {
            string key = keytxt.Value.Trim();
            sql += " and (admin like'%" + key + "%' or account like'%" + key + "%'  or  trackingno like'%" + key + "%')";
        }

        if (select.Value.Trim() != "0")
        {
            sql += " and (type like'%" + select.Value + "%' )";
        }
        DataLoad(sql);
    }
}
